package org.example.crm.common;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.stereotype.Service;

import java.time.Duration;

@Service
public class RedisService {
    public static final String TOKEN_PREFIX = "s59:crm:login:";

    @Autowired
    private StringRedisTemplate stringRedisTemplate;

    public void set(String key, String value, Duration timeout) {
        stringRedisTemplate.opsForValue().set(key, value, timeout);
    }

    public String get(String key) {
        return stringRedisTemplate.opsForValue().get(key);
    }

    public Boolean del(String key) {
        return stringRedisTemplate.delete(key);
    }
}
